package crp.core.analysis.domain.repositories;

import crp.core.analysis.domain.models.ViewFlowEntity;
import crp.core.course.domain.models.CourseEntity;
import crp.core.shared.PublicStatus;
import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase;

import javax.enterprise.context.ApplicationScoped;
import java.util.List;

@ApplicationScoped
public class ViewFlowRepository implements PanacheRepositoryBase<ViewFlowEntity, String> {

    public List<CourseEntity> topViewsPublicCourseIds(Integer limit) {
        String hql = "select c from CourseEntity c " +
                " where c.attributes.publicStatus=:publicStatus";
        return getEntityManager().createQuery(hql, CourseEntity.class)
                .setParameter("publicStatus", PublicStatus.PUBLIC)
                .setMaxResults(limit)
                .getResultList();
    }
}
